var app=angular.module('appncc',[])
app.controller('maincc',function($scope){
    $scope.f=function(){
        $scope.msg='欢迎填写';
    }
    $scope.b=function(){
        $scope.msg='您填写完成';
    }
    $scope.list=[
        {name:'张三',content:'我非常喜欢德克士',time:'2020-3-22',flag:false},
        {name:'李四',content:'我非常喜欢华莱士',time:'2020-3-2',flag:false},
        {name:'王五',content:'我非常喜欢星巴克',time:'2020-3-02',flag:false}
  ];
    $scope.getCount=function(){
        console.log($scope.newContent);
        if($scope.newContent.length>100){
            $scope.newContent=$scope.newContent.slice(0,100);
        }
        if($scope.newContent.length===0){
          
        }
        return 100-$scope.newContent.length;
    }
    $scope.add=function(){
        var obj = {
            name:$scope.newName,
            content:$scope.newContent,
            time:new Date().toLocaleDateString(),
            flag:false
        };
        $scope.list.unshift(obj);
        $scope.newName='';
        $scope.newContent='';
    }
    $scope.del=function(){
        $scope.list.forEach(function(item,index){
            if(item.flag){
                $scope.list.splice(index,1);
                $scope.del;
            }
        })
    }

   

   $scope.all=function(){
       $scope.list.forEach(function(item,index){
           item.flag=true;
       })
   }
   $scope.fan=function(){
       $scope.list.forEach(function(item,index){
          item.flag=!item.flag;
       })
   }
   
})